home *** CD-ROM | disk | FTP | other *** search
Wrap
/* File: OHCIFWIM.h Contains: Definitions for TI PCI-OHCI 1394 card FireWire interface module. Version: 1.0 Written by: Jay Lloyd Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved. File Ownership: DRI: Jay Lloyd Other Contact: Eric Anderson Technology: FireWire Writers: (jkl) Jay Lloyd Change History (most recent first): <FW8> 9/25/98 jkl Removed skip address from DMABuildState structure. <FW7> 8/26/98 jkl Cleaned up fwim data structure. <FW6> 8/7/98 jkl Added isochRxDummyQuadPhys field to fwim data to use in handling initial time stamp quad in isoch receive header. <FW5> 8/5/98 jkl Added some more isoch defines. <FW4> 8/4/98 jkl More define and structure clean up. <FW3> 7/28/98 jkl Cleaned up some more defines. <FW2> 7/27/98 jkl Clean up naming. <FW1> 7/24/98 jkl first checked in */ #ifndef __OHCIFWIM__ #define __OHCIFWIM__ #ifndef __TYPES__ #include <Types.h> #endif #ifndef __INTERRUPTS__ #include <Interrupts.h> #endif #ifdef __cplusplus extern "C" { #endif #if PRAGMA_IMPORT_SUPPORTED #pragma import on #endif #if PRAGMA_ALIGN_SUPPORTED #pragma options align=power #endif /*zzz*/ /* Isn't this PCI standard stuff? Shouldn't it be in some regular include */ /* file like PCI.h? */ #define bit0 0x00000001 #define bit1 0x00000002 #define bit2 0x00000004 #define bit3 0x00000008 #define bit4 0x00000010 #define bit5 0x00000020 #define bit6 0x00000040 #define bit7 0x00000080 #define bit8 0x00000100 #define bit9 0x00000200 #define bit10 0x00000400 #define bit11 0x00000800 #define bit12 0x00001000 #define bit13 0x00002000 #define bit14 0x00004000 #define bit15 0x00008000 #define bit16 0x00010000 #define bit17 0x00020000 #define bit18 0x00040000 #define bit19 0x00080000 #define bit20 0x00100000 #define bit21 0x00200000 #define bit22 0x00400000 #define bit23 0x00800000 #define bit24 0x01000000 #define bit25 0x02000000 #define bit26 0x04000000 #define bit27 0x08000000 #define bit28 0x10000000 #define bit29 0x20000000 #define bit30 0x40000000 #define bit31 0x80000000 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Configuration Registers * */ enum { kConfigStart = 0x00, cwVendorID = 0x00, cwDeviceID = 0x02, cwCommand = 0x04, cwStatus = 0x06, clClassCodeAndRevID = 0x08, clHeaderAndLatency = 0x0C, clBaseAddressZero = 0x10, /* I/O Base address */ clBaseAddressOne = 0x14, /* Memory Base address */ clExpansionRomAddr = 0x30, clLatGntIntPinLine = 0x3C, /* Max_Lat, Max_Gnt, Int. Pin, Int. Line */ cbGPIOzero = 0xFC, /* General Purpose Input/Output Control */ cbGPIOone = 0xFD, /* General Purpose Input/Output Control */ cbGPIOtwo = 0xFE, /* General Purpose Input/Output Control */ cbGPIOthree = 0xFF, /* General Purpose Input/Output Control */ kConfigEnd = 0x100 }; /* * 0x04 cwCommand Command Register (read/write) */ enum { cwCommandSERREnable = bit8, cwCommandEnableParityError = bit6, cwCommandEnableBusMaster = bit2, /* Set this on initialization */ cwCommandEnableMemorySpace = bit1, /* Respond at Base Address One if set */ cwCommandEnableIOSpace = bit0 /* Respond at Base Address Zero if set */ }; /* * 0x06 cwStatus Status Register (read/write) */ enum { cwStatusDetectedParityError = bit15, /* Detected from slave */ cwStatusSignaledSystemError = bit14, /* Device asserts SERR/ signal */ cwStatusMasterAbort = bit13, /* Master sets when transaction aborts */ cwStatusReceivedTargetAbort = bit12, /* Master sets when target-abort */ cwStatusDEVSELTimingMask = (bit10 | bit9), /* DEVSEL timing encoding R/O */ cwStatusDEVSELFastTiming = 0, cwStatusDEVSELMediumTiming = bit9, cwStatusDEVSELSlowTiming = bit10, cwStatusDataParityReported = bit8 }; /* * 0xFC cbGPIOzero GPIO zero control register (read/write) */ enum { DISABLE_BMC = bit7, // Disable Bus Manager Contender GPIO_INV0 = bit5, // Polarity Invert GPIO_ENB0 = bit4, // Output Enable control GPIO_DATA0 = bit0 // data when Disable_BMC is 1 }; //////////////////////////////////////////////////////////////////////////////// // // Useful macro defs. // #define EndianSwapImm32Bit(data32) \ ( \ (((UInt32) data32) >> 24) | \ ((((UInt32) data32) >> 8) & 0xFF00) | \ ((((UInt32) data32) << 8) & 0xFF0000) | \ (((UInt32) data32) << 24) \ ) #define OHCIBitRange(start, end) \ ( \ ((((UInt32) 0xFFFFFFFF) << (31 - (end))) >> \ ((31 - (end)) + (start))) << \ (start) \ ) #define OHCIBitRangePhase(start, end) \ (start) //////////////////////////////////////////////////////////////////////////////// // // FWIM data defs. // enum { kPacketBufferSize = 4096, // Needs to be large enough for largest asynch packet size and multiple of 32 kEndRxDMABufferSize = 2028, // Last receive buffer is 4096, but only request 2028, rest is used for contiguous space kSelfIDBufferSize = 2048, // Maximum self-ids we could receive is 2k kConfigROMBufferSize = 1024, // Size of physically mapped config ROM memory kAsynchQuadReadReqSize = 16, // 4 quads, size of asynch quadlet read request packet including header and trailer, no crc's kAsynchBlockWriteReqHeaderSize = 16, // 4 quads, size of asynch block write request packet header kAsynchQuadWriteReqSize = 20, // 5 quads, size of asynch quadlet write request packet including header and trailer, no crc's kAsynchBlockReadReqSize = 20, // 5 quads, size of asynch block read request packet including header and trailer, no crc's kAsynchTxDescriptorBlockSize = 128, // Maximum size of a descriptor block kNumAsynchTxDMADescriptorBlocks = 16, // Number of descriptors for transmit DMA // 8 for requests, 8 for responses kMaxBufPages = 6, // Max # of physical pages per packet kAsynchReqTxDMA = 0, // asynch transmit request DMA index kAsynchResTxDMA = 8, // asynch transmit response DMA index // JKL *** fix these numbers to determine a good balance between performance and memory kAsynchRxBufs = 60, // # of Asynch bufs kAsynchResRxFirstDMA = 0, // First asynch receive response packet DMA index. kAsynchResRxLastDMA = 39, // Last asynch receive response packet DMA index. kAsynchReqRxFirstDMA = 40, // First asynch receive request packet DMA index. kAsynchReqRxLastDMA = 59, // Last asynch receive request packet DMA index. kFWIMProcessAsynchParams = 40, // Number of FWIMProcessAsynchParam blocks created and queued // end of fix stuff // Isoch context stuff is hardwired to 1 receive and 1 transmit context for now kITContext0 = 0, // isoch transmit context 0 kIRContext0 = 0, // isoch receive context 0 kIsochReceiveDMA = 2, // kIsochTransmitDMA = 3, // kNumDMAPorts = 2, // Number of DMA channels. kIsochTransmitPort = 0, // Transmitting isoch port number. kIsochReceivePort = 1, // Receiving isoch port number. kNumDCLInterrupts = 30 // Number of DCL records allowed in interrupt list // JKL *** this needs to be handled dynamically }; // Strictly speaking, these defs are for the TI PHY TSB21LV03 and a 1394a PHY. // If OpenHCI is used with another PHY, these constants may change. //////////////////////////////////////////////////////////////////////////////// // // Phy registers. // // swapped bit definitions enum { kPhyBit0 = bit7, kPhyBit1 = bit6, kPhyBit2 = bit5, kPhyBit3 = bit4, kPhyBit4 = bit3, kPhyBit5 = bit2, kPhyBit6 = bit1, kPhyBit7 = bit0 }; #define PhyBitRange(start, end) \ ( \ (((((UInt32) 0xFF) << (start)) & 0xFF) >> \ ((start) + (7 - (end)))) << \ (7 - (end)) \ ) #define PhyBitRangePhase(start, end) \ (7 - end) // Phy register defs. // 1394 (TSB21LV03) PHY with old register set enum { kPhyPhysicalIDAddress = 0, kPhyPhysicalID = PhyBitRange (0, 5), kPhyPhysicalIDPhase = PhyBitRangePhase (0, 5), kPhyRAddress = 0, kPhyR = kPhyBit6, kPhyCPSAddress = 0, kPhyCPS = kPhyBit7, kPhyRHBAddress = 1, kPhyRHB = kPhyBit0, kPhyIBRAddress = 1, kPhyIBR = kPhyBit1, kPhyGCAddress = 1, kPhyGC = PhyBitRange (2, 7), kPhyGCPhase = PhyBitRangePhase (2, 7), kPhySPDAddress = 2, kPhySPD = PhyBitRange (0, 1), kPhySPDPhase = PhyBitRangePhase (0, 1), kPhyNPAddress = 2, kPhyNP = PhyBitRange (3, 7), kPhyNPPhase = PhyBitRangePhase (3, 7), kPhyPortStatusAddress = 3, kPhyAStat = PhyBitRange (0, 1), kPhyAStatPhase = PhyBitRangePhase (0, 1), kPhyBStat = PhyBitRange (2, 3), kPhyBStatPhase = PhyBitRangePhase (2, 3), kPhyPortStatus = PhyBitRange (4, 5), kPhyPortStatusPhase = PhyBitRangePhase (4, 5), kPhyCh = kPhyBit4, kPhyCon = kPhyBit5, kPhyCAddress = 6, kPhyC = kPhyBit7 }; // 1394a (TSB41LV06) PHY with Extended Register Set enum { kExtPhyPhysicalIDAddress = 0, kExtPhyPhysicalID = PhyBitRange (0, 5), kExtPhyPhysicalIDPhase = PhyBitRangePhase (0, 5), kExtPhyRAddress = 0, kExtPhyR = kPhyBit6, kExtPhyCPSAddress = 0, kExtPhyCPS = kPhyBit7, kExtPhyRHBAddress = 1, kExtPhyRHB = kPhyBit0, kExtPhyIBRAddress = 1, kExtPhyIBR = kPhyBit1, kExtPhyGCAddress = 1, kExtPhyGC = PhyBitRange (2, 7), kExtPhyGCPhase = PhyBitRangePhase (2, 7), kExtPhyExtAddress = 2, kExtPhyExt = PhyBitRange (0, 2), kExtPhyExtPhase = PhyBitRangePhase (0, 2), kExtPhyNPAddress = 2, kExtPhyNP = PhyBitRange (3, 7), kExtPhyNPPhase = PhyBitRangePhase (3, 7), kExtPhySPDAddress = 3, kExtPhySPD = PhyBitRange (0, 1), kExtPhySPDPhase = PhyBitRangePhase (0, 1), kExtPhyLinkAddress = 4, kExtPhyLink = kPhyBit0, kExtPhyCntdAddress = 4, kExtPhyCntd = kPhyBit1, kExtPhyDlyAddress = 4, kExtPhyDly = PhyBitRange (2, 3), kExtPhyDlyPhase = PhyBitRangePhase (2, 3), kExtPhyIRAddress = 4, kExtPhyIR = kPhyBit4, kExtPhyPwrAddress = 4, kExtPhyPwr = PhyBitRange (5, 7), kExtPhyPwrPhase = PhyBitRangePhase (5, 7), kExtPhyISBRAddress = 5, kExtPhyISBR = kPhyBit1, kExtPhyCTOIAddress = 5, kExtPhyCTOI = kPhyBit2, kExtPhyCPSIAddress = 5, kExtPhyCPSI = kPhyBit3, kExtPhySTOIAddress = 5, kExtPhySTOI = kPhyBit4, kExtPhyDPSIAddress = 5, kExtPhyDPSI = kPhyBit5, kExtPhyEAAAddress = 5, kExtPhyEAA = kPhyBit6, kExtPhyEMSCAddress = 5, kExtPhyEMSC = kPhyBit7, kExtPhyPingAddres = 6, kExtPhyPing = PhyBitRange (0, 7), kExtPhyPingPhase = PhyBitRangePhase (0, 7), kExtPhyPortAddres = 7, kExtPhyPort = PhyBitRange (3, 7), kExtPhyPortPhase = PhyBitRangePhase (3, 7), kExtPhyAStatnAddress = 8, kExtPhyAStatn = PhyBitRange (0, 1), kExtPhyAStatnPhase = PhyBitRangePhase (0, 1), kExtPhyBStatnAddress = 8, kExtPhyBStatn = PhyBitRange (2, 3), kExtPhyBStatnPhase = PhyBitRangePhase (2, 3), kExtPhyPortStatusnAddress = 8, kExtPhyPortStatusn = PhyBitRange (4, 5), kExtPhyPortStatusnPhase = PhyBitRangePhase (4, 5), kExtPhyChnAddress = 8, kExtPhyChn = kPhyBit4, kExtPhyConnAddress = 8, kExtPhyConn = kPhyBit5, kExtPhyBiasnAddress = 8, kExtPhyBiasn = kPhyBit6, kExtPhyDisnAddress = 8, kExtPhyDisn = kPhyBit7, kExtPhyPeerSpdnAddress = 9, kExtPhyPeerSpdn = PhyBitRange (0, 1), kExtPhyPeerSpdnPhase = PhyBitRangePhase (0, 1), kExtPhyInvalidAddress = 10 }; // OHCI DMA descriptor fields enum { kTCodeSelfID = 16 }; enum { kPacketTCode = OHCIBitRange(4, 7), kPacketTCodePhase = OHCIBitRangePhase(4, 7), kAsynchRt = OHCIBitRange(8, 9), kAsynchRtPhase = OHCIBitRangePhase(8, 9), kAsynchTLabel = OHCIBitRange(10, 15), kAsynchTLabelPhase = OHCIBitRangePhase(10, 15), kAsynchSpd = OHCIBitRange(16, 18), kAsynchSpdPhase = OHCIBitRangePhase(16, 18), kAsynchSrcBusID = bit23, kAsynchDestinationOffsetHigh = OHCIBitRange(0, 15), kAsynchDestinationOffsetHighPhase = OHCIBitRangePhase(0, 15), kAsynchDestinationID = OHCIBitRange(16, 31), kAsynchDestinationIDPhase = OHCIBitRangePhase(16, 31), kAsynchDestinationOffsetLow = OHCIBitRange(0, 31), kAsynchDestinationOffsetLowPhase = OHCIBitRangePhase(0, 31), kAsynchDataLength = OHCIBitRange(16, 31), kAsynchDataLengthPhase = OHCIBitRangePhase(16, 31), kAsynchRCode = OHCIBitRange(12, 15), kAsynchRCodePhase = OHCIBitRangePhase(12, 15) }; enum { kIsochTCode = OHCIBitRange (4, 7), kIsochTCodePhase = OHCIBitRangePhase (4, 7), kIsochTxChannel = OHCIBitRange (8, 13), kIsochTxChannelPhase = OHCIBitRangePhase (8, 13), kIsochTag = OHCIBitRange (14, 15), kIsochTagPhase = OHCIBitRangePhase (14, 15), kIsochTxSpeed = OHCIBitRange (16, 18), kIsochTxSpeedPhase = OHCIBitRangePhase (16, 18), kIsochTxDataLength = OHCIBitRange (16, 31), kIsochTxDataLengthPhase = OHCIBitRangePhase (16, 31) }; struct OHCIDMADescriptorStruct { UInt32 descriptorField[4]; }; typedef struct OHCIDMADescriptorStruct DMADescriptor, *DMADescriptorPtr; // Constants used in DMA descriptors enum { kOutputMoreCmd = 0, kOutputMoreKey = 0, kOutputMoreImmCmd = 0, kOutputMoreImmKey = 2, kOutputLastCmd = 1, kOutputLastKey = 0, kInterruptOnError = 1, kInterruptAlways = 3, kInterruptBadAck = 1, kInterruptNever = 0, kOutputMoreBranch = 0, kOutputLastBranch = 3, kOutputLastImmCmd = 1, kOutputLastImmKey = 2, kInputMoreCmd = 2, kInputMoreKey = 0, kInputLastCmd = 3, kInputLastKey = 0, kInputMoreBranch = 3, kBranchAlways = 3, kDMACommand = OHCIBitRange(28, 31), kDMACommandPhase = OHCIBitRangePhase(28, 31), kDMAInputStatus = bit27, kDMAKey = OHCIBitRange(24, 26), kDMAKeyPhase = OHCIBitRangePhase(24, 26), kDMAPing = bit23, kDMAInterrupt = OHCIBitRange(20, 21), kDMAInterruptPhase = OHCIBitRangePhase(20, 21), kDMABranch = OHCIBitRange(18, 19), kDMABranchPhase = OHCIBitRangePhase(18, 19), kDMAReqCount = OHCIBitRange(0, 15), kDMAReqCountPhase = OHCIBitRangePhase(0, 15), kDMAResCount = OHCIBitRange(0, 15), kDMAResCountPhase = OHCIBitRangePhase(0, 15), kDMATransferStatus = OHCIBitRange(16, 31), kDMATransferStatusPhase = OHCIBitRangePhase(16, 31), kDMATimeStamp = OHCIBitRange(0, 15), kDMATimeStampPhase = OHCIBitRangePhase(0, 15) }; // DMA context fields enum { kDMAEventCode = OHCIBitRange(0, 4), kDMAEventCodePhase = OHCIBitRangePhase(0, 4), kDMASpeed = OHCIBitRange(5, 7), kDMASpeedPhase = OHCIBitRangePhase(5, 7), kDMAActive = bit10, kDMADead = bit11, kDMAWake = bit12, kDMARun = bit15, // IR DMA context fields kIRDMAMultiChanMode = bit28, kIRDMACycleMatchEnable = bit29, kIRDMAIsochHeader = bit30, kIRDMABufferFill = bit31, // IT DMA context fields kITDMACycleMatch = OHCIBitRange(16, 30), kITDMACycleMatchPhase = OHCIBitRangePhase(16, 30), kITDMACycleMatchEnable = bit31 }; // IR DMA match fields enum { kIRDMAChannelNumber = OHCIBitRange(0, 5), kIRDMAChannelNumberPhase = OHCIBitRangePhase(0, 5), kIRDMATag1SyncFilter = bit6, kIRDMASync = OHCIBitRange(8, 11), kIRDMASyncPhase = OHCIBitRangePhase(8, 11), kIRDMACycleMatch = OHCIBitRange(12, 26), kIRDMACycleMatchPhase = OHCIBitRangePhase(12, 26), kIRDMATag0 = bit28, kIRDMATag1 = bit29, kIRDMATag2 = bit30, kIRDMATag3 = bit31 }; struct DMAContextStruct { volatile UInt32 controlSet; volatile UInt32 controlClear; volatile UInt32 reserved; volatile UInt32 commandPtr; }; typedef struct DMAContextStruct DMAContext, *DMAContextPtr; struct IRDMAContextStruct { volatile UInt32 controlSet; volatile UInt32 controlClear; volatile UInt32 reserved0; volatile UInt32 commandPtr; volatile UInt32 match; volatile UInt32 reserved1; volatile UInt32 reserved2; volatile UInt32 reserved3; }; typedef struct IRDMAContextStruct IRDMAContext, *IRDMAContextPtr; // OHCI register file struct OHCIRegistersStruct { volatile UInt32 version; volatile UInt32 guid_rom; volatile UInt32 atRetries; volatile UInt32 csrData; volatile UInt32 csrCompare; volatile UInt32 csrControl; volatile UInt32 configROMHdr; volatile UInt32 busID; volatile UInt32 busOptions; volatile UInt32 guidHi; volatile UInt32 guidLo; volatile UInt32 reserved0; volatile UInt32 reserved1; volatile UInt32 configROMMap; volatile UInt32 postedWriteAddressLo; volatile UInt32 postedWriteAddressHi; // 0x040 volatile UInt32 vendorID; volatile UInt32 reserved2; volatile UInt32 reserved3; volatile UInt32 reserved4; volatile UInt32 hcControlSet; volatile UInt32 hcControlClear; volatile UInt32 reserved5; volatile UInt32 reserved6; volatile UInt32 reserved7; volatile UInt32 selfIDBuffer; volatile UInt32 selfIDCount; volatile UInt32 reserved8; volatile UInt32 irMultiChanMaskHiSet; volatile UInt32 irMultiChanMaskHiClear; volatile UInt32 irMultiChanMaskLoSet; volatile UInt32 irMultiChanMaskLoClear; // 0x080 volatile UInt32 intEventSet; volatile UInt32 intEventClear; volatile UInt32 intMaskSet; volatile UInt32 intMaskClear; volatile UInt32 isochTxIntEventSet; volatile UInt32 isochTxIntEventClear; volatile UInt32 isochTxIntMaskSet; volatile UInt32 isochTxIntMaskClear; volatile UInt32 isochRxIntEventSet; volatile UInt32 isochRxIntEventClear; volatile UInt32 isochRxIntMaskSet; volatile UInt32 isochRxIntMaskClear; volatile UInt32 reserved9[11]; // 0x0DC volatile UInt32 fairnessControl; volatile UInt32 linkControlSet; volatile UInt32 linkControlClear; volatile UInt32 nodeID; volatile UInt32 phyControl; volatile UInt32 isochCycleTimer; volatile UInt32 reserved10; volatile UInt32 reserved11; volatile UInt32 reserved12; // 0x100 volatile UInt32 asynchRequestFilterHiSet; volatile UInt32 asynchRequestFilterHiClear; volatile UInt32 asynchRequestFilterLoSet; volatile UInt32 asynchRequestFilterLoClear; volatile UInt32 physicalRequestFilterHiSet; volatile UInt32 physicalRequestFilterHiClear; volatile UInt32 physicalRequestFilterLoSet; volatile UInt32 physicalRequestFilterLoClear; volatile UInt32 physicalUpperBound; volatile UInt32 reserved13[23]; // 0x180 DMAContext asynchRequestTxContext; volatile UInt32 reserved14[4]; DMAContext asynchResponseTxContext; volatile UInt32 reserved15[4]; DMAContext asynchRequestRxContext; volatile UInt32 reserved16[4]; DMAContext asynchResponseRxContext; volatile UInt32 reserved17[4]; // 0x200 DMAContext isochTxContext[32]; IRDMAContext isochRxContext[32]; }; typedef struct OHCIRegistersStruct OHCIRegisters, *OHCIRegistersPtr; // Enums for selected registers, etc. // Version register enum { kGUID_ROM = bit24, kVersion = OHCIBitRange(16, 23), kVersionPhase = OHCIBitRangePhase(16, 23), kRevision = OHCIBitRange(0, 7), kRevisionPhase = OHCIBitRangePhase(0, 7) }; // GUID ROM register enum { kAddrReset = bit31, kRdStart = bit25 // // JKL *** rdData is also defined as bits 16-23 in the phy register // kRdData = OHCIBitRange(16, 23), // kRdDataPhase = OHCIBitRangePhase(16, 23) }; // Asynch Transmit retry register enum { kSecondLimit = OHCIBitRange(29, 31), kSecondLimitPhase = OHCIBitRangePhase(29, 31), kCycleLimit = OHCIBitRange(16, 28), kCycleLimitPhase = OHCIBitRangePhase(16, 28), kMaxPhysRespRetries = OHCIBitRange(8, 11), kMaxPhysRespRetriesPhase = OHCIBitRangePhase(8, 11), kMaxATRespRetries = OHCIBitRange(4, 7), kMaxATRespRetriesPhase = OHCIBitRangePhase(4, 7), kMaxATReqRetries = OHCIBitRange(0, 3), kMaxATReqRetriesPhase = OHCIBitRangePhase(0, 3) }; // CSR Control register enum { kCSRDone = kBit31, kCSRSel = OHCIBitRange(0, 1), kCSRSelPhase = OHCIBitRangePhase(0, 1), kCHANNELS_AVAILABLE_LO = 3, kCHANNELS_AVAILABLE_HI = 2, kBANDWIDTH_AVAILABLE = 1, kBUS_MANAGER_ID = 0 }; // Config ROM Header register enum { kInfo_Length = OHCIBitRange(24, 31), kInfo_Length_Phase = OHCIBitRangePhase(24, 31), kCRC_Length = OHCIBitRange(16, 23), kCRC_Length_Phase = OHCIBitRangePhase(16, 23), kROM_CRC_Value = OHCIBitRange(0, 15), kROM_CRC_Value_Phase = OHCIBitRangePhase(0, 15) }; // Bus Options register enum { kIRMC = bit31, // isochronous resource maanger capable kCMC = bit30, // cycle master capable kISC = bit29, // isochronous support capable kBMC = bit28, // bus manager capable kPMC = bit27, // power management capable kCyc_Clk_Acc = OHCIBitRange(16, 23), // cycle clock accuracy kCyc_Clk_Acc_Phase = OHCIBitRangePhase(16, 23), kMax_Rec = OHCIBitRange(12, 15), // max receive packet size kMax_Rec_Phase = OHCIBitRangePhase(12, 15), kG = OHCIBitRange(6, 7), // generation counter kG_Phase = OHCIBitRangePhase(6, 7), kLink_Spd = OHCIBitRange(0, 2), // cycle clock accuracy kLink_Spd_Phase = OHCIBitRangePhase(0, 2) }; // Config ROM Mapping register enum { kConfigROMAddr = OHCIBitRange(10, 31), kConfigROMAddrPhase = OHCIBitRangePhase(10, 31) }; // Host Controller Control register enum { kNoByteSwapData = bit30, kProgramPhyEnable = bit23, kAPhyEnhanceEnable = bit22, kLPS = bit19, kPostedWriteEnable = bit18, kLinkEnable = bit17, kSoftReset = bit16 }; // Self ID Count register enum { kSelfIDError = bit31, kSelfIDGen = OHCIBitRange(16, 23), kSelfIDGenPhase = OHCIBitRangePhase(16, 23), kSelfIDSize = OHCIBitRange(2, 10), kSelfIDSizePhase = OHCIBitRangePhase(2, 10) }; // Interrupt Event register enum { kMasterIntEnable = bit31, kPhyRegRcvd = bit26, kCycleTooLong = bit25, kUnrecoverableError = bit24, kCycleInconsistent = bit23, kCycleLost = bit22, kCycle64Seconds = bit21, kCycleSynch = bit20, kPhyInt = bit19, kBusReset = bit17, kSelfIDComplete = bit16, kLockRespErr = bit9, kPostedWriteErr = bit8, kIsochRx = bit7, kIsochTx = bit6, kRSPkt = bit5, kRQPkt = bit4, kARRS = bit3, kARRQ = bit2, kRespTxComplete = bit1, kReqTxComplete = bit0 }; // some missing // GPIO Control Register A and B enum { kOHCIGPIO_OUT_EN0 = bit0, kOHCIGPIO_POL_OUT0 = bit2, kOHCIGPIO_SRC0 = OHCIBitRange(8, 12), kOHCIGPIO_SRC0Phase = OHCIBitRangePhase(8, 12), kOHCIGPIO_OUT_EN1 = bit16, kOHCIGPIO_POL_OUT1 = bit18, kOHCIGPIO_SRC1 = OHCIBitRange(24, 28), kOHCIGPIO_SRC1Phase = OHCIBitRangePhase(24, 28), kOHCIGPIO_OUT_EN2 = bit0, kOHCIGPIO_POL_OUT2 = bit2, kOHCIGPIO_SRC2 = OHCIBitRange(8, 12), kOHCIGPIO_SRC2Phase = OHCIBitRangePhase(8, 12), kOHCIGPIO_OUT_EN3 = bit16, kOHCIGPIO_POL_OUT3 = bit18, kOHCIGPIO_SRC3 = OHCIBitRange(24, 28), kOHCIGPIO_SRC3Phase = OHCIBitRangePhase(24, 28) }; // DMA OpenHCI events enum { kEvtNoStatus = 0, kEvtLongPacket = 2, kEvtMissingAck = 3, kEvtUnderrun = 4, kEvtOverrun = 5, kEvtDescriptorRead = 6, kEvtDataRead = 7, kEvtDataWrite = 8, kEvtBusReset = 9, kEvtTimeout = 10, kEvtTCodeErr = 11, kEvtUnknown = 14, kEvtFlushed = 15, kEventType = bit4 }; // Link Control register enum { kCycleSource = bit22, kCycleMaster = bit21, kCycleTimerEnable = bit20, kRcvPhyPkt = bit10, kRcvSelfID = bit9, kA_Phy = bit4 }; // Node ID and Status register enum { kIDValid = bit31, kRoot = bit30, kCPS = bit27, kBusNumber = OHCIBitRange(6, 15), kBusNumberPhase = OHCIBitRangePhase(6,15), kNodeNumber = OHCIBitRange(0, 5), kNodeNumberPhase = OHCIBitRangePhase(0, 5), kBusNumberNodeNumber = OHCIBitRange(0, 15), kBusNumberNodeNumberPhase = OHCIBitRangePhase(0, 15) }; // Phy Control register enum { kPhyRdDone = bit31, kPhyRdAddr = OHCIBitRange(24, 27), kPhyRdAddrPhase = OHCIBitRangePhase(24, 27), kPhyRdData = OHCIBitRange(16, 23), kPhyRdDataPhase = OHCIBitRangePhase(16, 23), kPhyRdReg = bit15, kPhyWrReg = bit14, kPhyRegAddr = OHCIBitRange(8, 11), kPhyRegAddrPhase = OHCIBitRangePhase(8, 11), kPhyWrData = OHCIBitRange(0, 7), kPhyWrDataPhase = OHCIBitRangePhase(0, 7) }; // Cycle Timer register enum { kCycleSeconds = OHCIBitRange(25, 31), kCycleSecondsPhase = OHCIBitRangePhase(25, 31), kCycleCount = OHCIBitRange(12, 24), kCycleCountPhase = OHCIBitRangePhase(12, 24), kCycleOffset = OHCIBitRange(0, 11), kCycleOffsetPhase = OHCIBitRangePhase(0, 11) }; // Defs for pending FWIM commands. enum { kPendingFWIMCommandBusy = 1 }; struct IsochPortDataStruct { DCLProgramID dclProgramID, // ID of DCL program we're using. originalDCLProgramID, // Original DCL program ID. translatedDCLProgramID; // Translated DCL program ID. UInt32 channelNum; // Isoch channel number used for this port. UInt32 speed; // Speed of this port. Boolean talking; // True if port is for talking. }; typedef struct IsochPortDataStruct IsochPortData, *IsochPortDataPtr; // put this typedef up here so it is available to the next two definitions typedef struct OHCIFWIMDataStruct OHCIFWIMData, *FWIMDataPtr; typedef struct AsynchRxDMADataStruct AsynchRxDMAData, *AsynchRxDMADataPtr; struct AsynchRxDMADataStruct { AsynchRxDMADataPtr pNextAsynchRxDMAData; // Logical pointer to next descriptor. FWIMDataPtr pFWIMData; // Pointer to OHCI FWIM data. DMADescriptorPtr pDMA; // Logical pointer to descriptor. Ptr pDMAPhysical; // Physical pointer to descriptor. Ptr packetBuffer; // Logical packet buffer of DMA. UInt32 packetStart; // Index into packet buffer for start of next packet }; struct FWIMProcessAsynchParamsQElem { QElemPtr qLink; // queue link in header SInt16 qType; // type FWIMDataPtr pFWIMData; // Pointer to OHCI FWIM data. AsynchRxDMADataPtr pAsynchRxDMAData; // DMA data record FWIMProcessAsynchParams fwimProcessAsynchParams; // the process params data Boolean DMAFull; // true if the DMA descriptor is complete }; typedef struct FWIMProcessAsynchParamsQElem FWIMProcessAsynchParamsQElem, *FWIMProcessAsynchParamsQElemPtr; typedef struct AsynchTxDMADataStruct AsynchTxDMAData, *AsynchTxDMADataPtr; struct AsynchTxDMADataStruct // information for a transmit desciptor block, not a single descriptor { // each one of these holds up to 8 descriptors, 128 bytes AsynchTxDMADataPtr pNextAsynchTxDMAData; // Logical pointer to next descriptor. FWIMDataPtr pFWIMData; // Pointer to OHCI FWIM data. DMADescriptorPtr pDMA; // Logical pointer to descriptor. Ptr pDMAPhysical; // Physical pointer to descriptor. IOPreparationTable ioPrep; // Used for prep'ing transmit buffers. UInt32 numDMADescriptors; // Number of descriptors that make up this descriptor block }; typedef struct DCLProgramInterruptStruct DCLProgramInterrupt, *DCLProgramInterruptPtr; struct DCLProgramInterruptStruct { DCLCommandPtr pDCLCommand; // Pointer to DCL command that caused interrupt Boolean pendingInterrupt; // true if DCL needs interrupt processing }; // Private data structure for OHCIFWIM - one per OHCI struct OHCIFWIMDataStruct { DCLProgramInterrupt pDCLInterruptList[kNumDMAPorts][kNumDCLInterrupts]; // List of DCLs that cause an interrupt, one list for each port, JKL *** hardwired to 2 UInt32 numDCLInterrupts[kNumDMAPorts]; // count of above DCL interrupts // JKL *** not good, fix this Ptr selfIDBuf; // buffer for self ids ... PhysicalAddress selfIDBufPhys; // and its physical address Ptr pActiveConfigROM; // logic address of active config ROM buffer PhysicalAddress pActiveConfigROMPhys; // Physical address of active config ROM buffer Ptr pNextConfigROM; // logic address of next config ROM buffer PhysicalAddress pNextConfigROMPhys; // Physical address of next config ROM buffer UInt32 isochContexts; // number of isoch contexts implemented in the OpenHCI link QHdrPtr pFWIMProcessAsynchParamsQueue; // queue for PhysicalAddress fwimDataPhys; // Physical address of this struct IOPreparationTable fwimDataIOPrep; // ioPrep data for this struct FWIMID fwimID; // ID for this FWIM RegEntryID FWIMRegEntryID; // Name registry ID for TI card. UInt32 generation; // Current bus generation number. Boolean generationValid; // Generation number is valid. Boolean root; // True if we're root. TimerID resetDebounceTimerID; // TimerID for debouncing resets Boolean resetDebounceTimerSet; // Flag indicating the above timer is running TimerID requestTimeoutTimerID; // TimerID to indicate timeout of a read/write request Boolean requestTimeoutTimerSet; // Flag indicating the above timer is running TimerID selfidTimeoutTimerID; // TimerID to indicate timeout of selfid receive Boolean selfidTimeoutTimerSet; // Flag indicating the above timer is running FWDeferredTaskID busResetDeferredTaskID; // Deferred task ID for handling bus resets. Boolean busResetDTScheduled; // True if we've scheduled a DT to handle bus resets. FWDeferredTaskID selfIDDeferredTaskID; // Deferred task ID for handling self ids. Boolean selfIDDTScheduled; // True if we've scheduled a DT to handle self ids. FWDeferredTaskID unrecoverableErrorDeferredTaskID; // Deferred task ID for handling unrecoverable error interrupts. Boolean unrecoverableErrorDTScheduled; // True if we've scheduled a DT to handle unrecoverable errors. FWDeferredTaskID asynchReqRxPktDeferredTaskID; // Deferred task ID for handling received asynch request packets. Boolean asynchReqRxPktDTScheduled; // True if we've sceduled a DT to handle received asynch request packets. FWDeferredTaskID asynchResRxPktDeferredTaskID; // Deferred task ID for handling received asynch response packets. Boolean asynchResRxPktDTScheduled; // True if we've sceduled a DT to handle received asynch response packets. FWDeferredTaskID asynchReqRxDMADeferredTaskID; // Deferred task ID for handling received asynch request DMA interrupts. Boolean asynchReqRxDMADTScheduled; // True if we've sceduled a DT to handle received asynch request DMA interrupts. FWDeferredTaskID asynchResRxDMADeferredTaskID; // Deferred task ID for handling received asynch response DMA interrupts. Boolean asynchResRxDMADTScheduled; // True if we've sceduled a DT to handle received asynch response DMA interrupts. FWDeferredTaskID isochReceiveDeferredTaskID; // Deferred task ID for handling received isoch packets. Boolean isochReceiveDTScheduled; // True if we've sceduled a DT to handle received isoch packets. FWDeferredTaskID isochTransmitDeferredTaskID; // Deferred task ID for handling transmitted isoch packets. Boolean isochTransmitDTScheduled; // True if we've sceduled a DT to handle transmitted isoch packets. FWDeferredTaskID asynchReqTxDeferredTaskID; // Deferred task ID for handling asynch transmit request interrupts. Boolean asynchReqTxDTScheduled; // True if we've sceduled a DT to handle asynch transmit request interrupts. FWDeferredTaskID asynchResTxDeferredTaskID; // Deferred task ID for handling asynch transmit response interrupts. Boolean asynchResTxDTScheduled; // True if we've sceduled a DT to handle asynch transmit response interrupts. FWIMCommandParamsPtr pPendingFWIMCommand; // Pending FWIM command. OSStatus pendingFWIMCommandStatus; // Internal status of pending FWIM command. FWIMCommandParamsPtr pPendingFWIMResponseCommand; // Pending FWIM response command. UInt32 transactionLabel; // Label used for current transaction UInt32 tCode; // TCode for current transaction. InterruptSetMember interruptSetMember; void *oldInterruptRefCon; InterruptHandler oldInterruptHandler; InterruptEnabler interruptEnabler; InterruptDisabler interruptDisabler; OHCIRegistersPtr pOHCIRegisters; // Register file Ptr asynchRxBuf[kAsynchRxBufs]; // Asynch receive buffers ... Ptr asynchRxBufPhys[kAsynchRxBufs]; // and their physical address DMADescriptorPtr asynchRxDMA; // Asynch receive DMA descriptors, block of kAsynchRxBufs Ptr asynchRxDMAPhys; // and their physical address AsynchRxDMADataPtr asynchRxDMADataList; // List of data records for asynch receive AsynchRxDMADataPtr pNextAsynchReqRxDMAData; // Next asynch receive request DMA to process. AsynchRxDMADataPtr pLastAsynchReqRxDMAData; // Last available asynch receive request DMA descriptor. AsynchRxDMADataPtr pNextAsynchResRxDMAData; // Next asynch receive response DMA to process. AsynchRxDMADataPtr pLastAsynchResRxDMAData; // Last available asynch receive response DMA descriptor. AsynchRxDMADataPtr pStartAsynchReqRxDMAData; // DMA data record to start asynch receive request program. AsynchRxDMADataPtr pStartAsynchResRxDMAData; // DMA data record to start asynch receive response program. AsynchRxDMADataPtr pEndAsynchReqRxDMAData; // DMA data record with buffer at the end of the contiguous buffer space. AsynchRxDMADataPtr pEndAsynchResRxDMAData; // DMA data record with buffer at the end of the contiguous buffer space. DMADescriptorPtr asynchTxDMA; // Asynch transmit DMA descriptors ... Ptr asynchTxDMAPhys; // and their physical address AsynchTxDMADataPtr asynchTxDMADataList; // List of descriptor block data records for asynch transmit. AsynchTxDMADataPtr pNextAsynchReqTxDMAData; // Next asynch transmit request DMA data record to use. AsynchTxDMADataPtr pFirstAsynchReqTxDMAData; // First asynch transmit request DMA data record to process. AsynchTxDMADataPtr pNextAsynchResTxDMAData; // Next asynch transmit response DMA data record to use. AsynchTxDMADataPtr pFirstAsynchResTxDMAData; // First asynch transmit response DMA data record to process. IOPreparationTable ioPrep; // For VM PhysicalAddress physAddrs[kAsynchRxBufs+20]; // Page table - fix this, arbitrary constant, could allocate exact amount and deallocate IsochPortDataPtr isochPortDataList[kNumDMAPorts]; // List of isoch port data records. UInt32 pageSize, // Physical page size and shift for VM. pageShift; Boolean extendedPhyRegs; // True if we have a 1394a PHY with the extended register set UInt32 phySpeed; // Some 400 phys also include their own self-id in self-id buffer but are not extended. // Use speed for another check to remove self-ids. UInt32 localSelfIDQuads[8]; // Support lots of ports. Overkill probably UInt8 selfIDPacketBuffer[2048]; // The actual self-id packets UInt32 numPHYPorts; // Number of ports supported by the PHY UInt32 *csrROMUpdateClearWhenDone; // For managing physical CSR ROM updates. SInt32 busResetCount; // counter for synching bus resets with asynch receive }; typedef struct DMAPoolDataStruct DMAPoolData, *DMAPoolDataPtr; struct DMAPoolDataStruct { DMAPoolDataPtr pNextDMAPoolData; // Link to next DMA pool data record. UInt32 nextFreeDMA; // Next free DMA in pool. UInt32 DMAPoolCount; // Number of DMA descriptors in pool. DMADescriptorPtr DMAPoolBase; // 16-byte-aligned DMA pool base address. UInt32 DMAPoolBasePhys; // Physical addr of same IOPreparationTable ioPrep; // For VM PhysicalAddress physAddrs[1]; // warning, if DMA pools gets larger than a page increment this }; // We create one of these for each DCL command to hold compiler private information: struct DCLCompilerDCLDataStruct { DMADescriptorPtr pDMA; // pointer to (first) descriptor PhysicalAddress pDMAPhys; // Physical address of same }; typedef struct DCLCompilerDCLDataStruct DCLCompilerDCLData, *DCLCompilerDCLDataPtr; // As we compile DCLs into DMA programs, this structure keeps track of general // information. There is one of these for each program being compiled. struct DCLCompilerEngineDataStruct { FWIMDataPtr pFWIMData; // Our FWIM data. UInt32 pStartDMA; // Physical address of first descriptor block in program, includes Z value. DMAPoolDataPtr pDMAPoolDataList; // List of DMA pools allocated for this compiled program. UInt32 engineGeneration; // For faster lookups UInt32 startEvent; // start event for the DMA program UInt32 startEventState; // if start event is cycleMatch, contains cycle count IOPreparationTable ioPrep; // For all buffers/etc DCLCompilerDCLDataPtr pDCLCompilerDCLData; // Base of compiler data list }; typedef struct DCLCompilerEngineDataStruct DCLCompilerEngineData, *DCLCompilerEngineDataPtr; // As we compile DCLs into DMA programs, this structure keeps track of DMA-oriented // information. There is one of these for each program being compiled. struct DMABuildStateStruct { FWIMDataPtr pFWIMData; // Our FWIM data. DCLCompilerEngineDataPtr pDCLCompilerEngineData; // Compiler engine data. DMAPoolDataPtr pDMAPoolDataList; // List of DMA pools allocated for this build. UInt32 dmaPortNum; // DMA port number we're building for. UInt32 isochChannelNum; // Isochronous channel number. UInt32 *pLastBranch; // unfilled branch from last DMA UInt32 isochRxDummyQuadPhys; // dummy quad address used to skip over timeStamp quad for isoch receive UInt16 tagBits; // tag bits set by a DCL command UInt16 syncBits; // sync bits set by a DCL command }; typedef struct DMABuildStateStruct DMABuildState, *DMABuildStatePtr; #if PRAGMA_ALIGN_SUPPORTED #pragma options align=reset #endif #if PRAGMA_IMPORT_SUPPORTED #pragma import off #endif #ifdef __cplusplus } #endif #endif /* __OHCIFWIM__ */